Skip to content

fix(canvas): honor the system clipboard - #698

Merged
FayeSpica merged 8 commits into
ThinkFlowLab:mainfrom
FayeSpica:feat/canvas-system-clipboard
Dec 5, 2026
Merged

FayeSpica merged 8 commits into
ThinkFlowLab:mainfrom
FayeSpica:feat/canvas-system-clipboard

Conversation

@FayeSpica

@FayeSpica FayeSpica commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Copying outside OpenDirector after copying a canvas node could leave the canvas pasting the earlier node. The same paste path now handles ordinary clipboard content and canvas fragments.

What changed

  • Use the browser's copy, cut, and paste events. Copy text nodes as plain text and support pasted text, image data, and media files.
  • Parse clipboard HTML into a data tree outside the browser document.
  • Keep same-browser cross-project paste on the existing asset registration path. Guard deferred writes when the destination changes.
  • Read the current clipboard from the Paste menu and show a localized shortcut hint if access is denied. Reject oversized UTF-8 text before creating a node.

Scope

Canvas clipboard behavior. No linked issue. Builds on #689. Native file export and cross-browser graph transfer are outside this change. A separate commit restores the Ark availability test to the required Python shard after the same inventory check failed on main.

Verification

  • Passed npm test, npm run build, npm run check:i18n, npm run check:browser-locale, and npm run check:browser-manifest.
  • macOS Chromium reproduced the old-paste failure on main. The candidate passed bilingual system clipboard, cross-project and source-closed cross-tab paste, paste ordering, undo, oversized UTF-8 text rejection, and HEIF original-byte fallback.
  • Firefox and WebKit passed the bilingual keyboard clipboard smoke check. Model-dependent cases use an isolated fixture, with no real-provider calls.
  • Passed targeted Python shard and Ark tests plus the real Chrome/FFmpeg motion-render test that failed to launch Chrome in the previous run.
  • Updated CodeQL and Release checks are pending. Clipboard testing used macOS browsers.
  • Independent candidate review: 90/100. Base 93bd25b08a53633c08a9d904b1043e8cf6c2de65. Head 14047d75c5f4f885ca0e9668080d877dd3386c1a.

Evidence

The before-and-after screenshots and cross-tab result and the playable recording use application commit cd82ad1ae2294decdd3162806228922b2117bd86. The final commit adds only these artifacts.

## summary

- Route canvas shortcuts through browser clipboard events and use the
  current clipboard for menu paste.
- Accept text, media files and supported HTML images while preserving
  editor focus and same-browser canvas fragments.
- Reuse registered assets across projects and cover external clipboard
  replacement, cutting, menu paste and reopened results.
## summary

- Let a stale file input event target defer to canvas focus while
  retaining protection for text editors and dialogs.
## summary

- Capture the baseline and corrected paste path on an isolated project.
- Record the browser clipboard workflow and the reopened destination.
## summary

- Check the UTF-8 byte limit before creating a pasted text node.
- Exercise oversized multibyte text in both browser locales.
## summary

- Record the clipboard workflow after correcting UTF-8 size validation.
- Show the oversized text rejection and the reopened destination.
@FayeSpica FayeSpica added type:bug Something is broken area:canvas Canvas, nodes and direct manipulation labels Dec 5, 2026

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMMENT(非表决) ed0044e Refs #689

技术意见:建议修改后复审。

当前证据暂定 82/100,非批准分(范围 3、正确性 2、验证 2、主张证据 3、简洁度 2)。我下载播放了 11.84 秒录像,核对了三张截图和资产 blob;录制的应用提交到当前 tip 只增加演示素材。旧节点不再盖过外部 clipboard、文本成节点、图片粘贴和大文本拒绝都有可见证据。没有独立运行应用或安装包。

还有一个并发顺序缺口:异步图片/跨项目素材尚未完成时,后粘贴的文本可以先写入;较早的素材之后落地反抢 selection,也改变 Undo 的顺序。我把建议留在入口。当前 Release 未全绿。

English: 82/100 provisional. The new clipboard evidence is viewable; mixed async/sync pastes can commit out of user order.

Dot,代表 @david6666666。非表决评审,先修复顺序并补对应回归。

const snapshot = snapshotClipboard(event.clipboardData);
if (!snapshot.files.length && !snapshot.html && !snapshot.text.trim()) return;
event.preventDefault();
void pasteContent(snapshot, pasteDestination());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每次 paste 都立即启动独立任务。第一笔如果在等图片读取或跨项目素材注册,第二笔纯文本会先 commit;第一笔晚到又改 selection,Undo 也先撤掉旧操作。visit guard 只能防切项目,不能保序。建议在同一次项目打开期间串行提交并让失败释放队列,补一个「慢图片 → 紧接文本」的测试,核对节点提交、selection 和 Undo 顺序。

## summary

- Extract clipboard markers and image sources from a parse5 data tree.
- Keep clipboard HTML out of browser HTML setters and exercise the
  parser without a browser document.
## summary

- Register the Ark availability module in the Python shard inventory.
- Record the inventory failure observed on main and PR 698.
## summary

- Refresh the browser artifacts with the data-tree clipboard parser.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMMENT(非表决) 14047d7 Refs #689

88/100(范围 3、正确性 2、验证 3、主张证据 3、简洁度 2)。新提交把 Clipboard HTML 改成数据解析,不再交给活跃 DOM;该 head 的 Release、CodeQL 和 DSH 均通过。我下载并解码了新版 11.88 秒录屏,文件和两张新截图都匹配当前 blob;录制的应用版本到 tip 只补证据。未独立运行程序。

技术上仍建议先修再合:上轮提到的提交顺序没变,剪贴板解析调整没有改到异步 paste 完成、selection 和 Undo 的顺序。已有意见不再另贴一遍。不是因为落后 main,也不是因为 CI。

English: 88/100. Exact-head CI and revised media are green; the async paste ordering finding remains.

Dot,代表 @david6666666。非表决评审。

@FayeSpica
FayeSpica merged commit 4cd524c into ThinkFlowLab:main Dec 5, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:canvas Canvas, nodes and direct manipulation type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants